
import 'package:eshi/app/shi/data/HistoryMarks.dart';
import 'package:eshi/app/shi/data/System.dart';
import 'package:eshi/app/shi/data/parse/FileParser.dart';
import 'package:eshi/app/shi/widget/BaseTextWidget.dart';
import 'package:flutter/material.dart';

class DocTextWidget extends BaseTextWidget {
  @override
  HistoryMarks type = HistoryMarks.doc;
  // IconData? icon= Icons.edit;
  DocTextWidget({super.key, required super.text, required super.child,super.showChild });

  bool get isTextFile => assetPath.endsWith(".txt");
  RemmberData get  fileContent => remmber(FileParser.getTextContent(assetPath));

  @override
  onOpen() => isTextFile ? super.onOpen() : System.open(assetPath);

  @override
  Widget page(){
      if(isTextFile){
        return Container(
            padding: EdgeInsets.all(10),
            color: Colors.grey,
            child: SizedBox(width: 500,height: 200,child:  SingleChildScrollView (
              child: Text(fileContent.value)
            )),
        ) ; 
      }else{
        return iconPage(icon: Icon(Icons.edit_document));
      }
  }
}